@extends('admin')

@section('content')

    <div class="nav">
        <ul class="cc">
            <li>
                <a href="{{url('admin/areas')}}">城市管理</a>
            </li>
            <li class="current">
                <a href="{{url('admin/areas/district')}}">商圈管理</a>
            </li>
        </ul>
    </div>

    <p class="mb10">
        <a href="{{url('admin/areas/distupdate')}}" class="btn J_dialog" title="新增商圈"><span class="add"></span>新增商圈</a>
    </p>

    <div class="h_a">搜索</div>
    <div class="search_type cc mb10">
        <form action="{{url('admin/areas/district')}}" method="get" class="search_form">
            <label for="prov_id">按地区：</label>
            <select name="prov_id" id="prov_id" class="mr10">
                <option value="">全部</option>
                @foreach ($provinces as $province)
                    <option @if ($prov_id == $province->id) selected="selected" @endif value="{{$province->id}}">{{$province->name}}</option>
                @endforeach
            </select>
             -
            <select name="city_id" id="city_id" class="mr10">
                <option value="">全部</option>
                @foreach ($city as $c)
                    <option @if ($city_id == $c->id) selected="selected" @endif value="{{$c->id}}">{{$c->name}}</option>
                @endforeach
            </select>
            -
            <select name="area_id" id="area_id" class="mr10">
                <option value="">全部</option>
                @foreach ($area as $c)
                    <option @if ($area_id == $c->id) selected="selected" @endif value="{{$c->id}}">{{$c->name}}</option>
                @endforeach
            </select>

            <label for="search_name">名称：</label><input type="text" name="name" value="{{$name}}" id="search_name" class="input length_2"/>
            <button type="submit" class="btn">提交查询</button>
        </form>

    </div>

    <div class="table_list">
        <div id="data_list">
            <table class="items">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>商圈名称</th>
                    <th>是否热门</th>
                    <th>省份</th>
                    <th>城市</th>
                    <th>区县</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($list as $item)
                    <tr>
                        <td>{{$item->id}}</td>
                        <td>{{$item->name}}</td>
                        <td>@if ($item->is_hot) <span class="green">是</span> @else <span class="red">否</span> @endif</td>
                        <td>{{$item->province->name}}</td>
                        <td>{{$item->city->name}}</td>
                        <td>{{$item->area->name}}</td>
                        <td>
                            <a href="{{url('admin/areas/distupdate/'.$item->id)}}" title="编辑{{$item->name}}" class="mr10 J_dialog">[编辑]</a>
                            <a href="{{url('admin/areas/distdelete/'.$item->id)}}" class="mr10 J_ajax_del">[删除]</a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>

        <div class="summary">
            共有 {{$list->total()}} 条数据
        </div>
        @if ($list->hasPages())
            <div class="pager">
                <!--
                <span style="float:left; margin-right:10px;">
                    转至<input type="text" id="goToPage" class="input" style="width:30px; text-align:center;">页
                    <span onclick="goto();" class="btn btn_submit">跳转</span>
                </span>
                -->
                {!! $list->appends($appends)->render() !!}
            </div>
        @endif
    </div>

@stop

@section('js')
    @parent
    <script src="{{asset('/js/admin/admin.js')}}"></script>
    <script>
        $('#prov_id').on('change', function () {
            reloadOptions($(this).val(), $('#city_id'), 'Area', '', '', $('#area_id'));
        });

        $('#city_id').on('change', function () {
            reloadOptions($(this).val(), $('#area_id'), 'Area');
        });
    </script>
@endsection